﻿using UnityEngine;
using System.Collections;

public class Mob {

	public xy pos;
	public Data_Sprite dataSprite;

	public GameObject go;
	public SpriteRenderer r;

	Vector3 vectorPos;
	Vector3 vectorScale;

	public void create(string name) {
		go = new GameObject (name);
		go.transform.SetParent (Tappa.game.liveObjectsFolder.transform);
		vectorPos = new Vector3 (0, 0, 0);
		vectorScale = new Vector3 (1, 1, 1);		
		r = go.AddComponent<SpriteRenderer> ();
	}

	public void init(Data_Sprite a) {
		dataSprite = a;
		pos = a.pos;	
		upd ();
	}

	public void upd() {
		vectorPos.x = pos.x;
		vectorPos.y = pos.y;
		go.transform.localPosition = vectorPos;
		vectorScale.x = dataSprite.size.x;
		vectorScale.y = dataSprite.size.y;
		go.transform.localScale = vectorScale;
		r.sprite = dataSprite.sprite;
		r.sortingLayerID = dataSprite.layer;
	}

	public static Beer temporalSingularity = null;

}
